package com.sttk.secreconeclick.bookkeep.adapter;

import android.view.View;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.lzb.basic.ProviderMultiAdapter;
import com.sttk.secreconeclick.bookkeep.R;
import com.sttk.secreconeclick.bookkeep.bean.AccountBookBean;

import org.jetbrains.annotations.NotNull;


public class SelAccountBookAdapter extends ProviderMultiAdapter<AccountBookBean> {

    private int selPosition;

    public SelAccountBookAdapter() {
        addItemProvider(new SelAccountBookItemProvider());
    }

    public void setSelPosition(int selPosition) {
        this.selPosition = selPosition;
        notifyDataSetChanged();
    }

    private class SelAccountBookItemProvider extends BaseItemProvider<AccountBookBean> {
        @Override
        public int getItemViewType() {
            return ProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_sel_account_book;
        }

        @Override
        public void convert(@NotNull BaseViewHolder baseViewHolder, AccountBookBean bean) {
//            if (baseViewHolder.getBindingAdapterPosition() == selPosition) {
//                baseViewHolder.itemView.setVisibility(View.GONE);
//            } else {
//                baseViewHolder.itemView.setVisibility(View.VISIBLE);
//            }
            baseViewHolder.setText(R.id.tvSelAccountBookItemName, bean.getName());
            if (bean.isSelected()) {
                baseViewHolder.setImageResource(R.id.ivSelAccountBookItemSel, R.drawable.yes);
            } else {
                baseViewHolder.setImageResource(R.id.ivSelAccountBookItemSel, R.drawable.no);
            }
        }
    }
}
